/**
 * @file sport.h
 * @brief 歌曲文件导入头文件
 */

#ifndef MP3_IMPORT_H_INCLUDED
#define MP3_IMPORT_H_INCLUDED

/**********************
 * TYPEDEF
 **********************/

// 编码列表
typedef enum {
    ENCODING_UNKNOWN,
    ENCODING_UTF8,
    ENCODING_UTF8_BOM,
    ENCODING_GBK,
    ENCODING_UTF16_LE,
    ENCODING_UTF16_BE,
    ENCODING_OTHER
} EncodingType;

/**********************
 * GLOBAL PROTOTYPES
 **********************/

int mp3_import_main();
int delete_file(const char* file_path, int flag);
char* open_file_dialog();

int check_file_extension(const char* fileName, const char* expectedExt);

const char* get_file_extension(const char* fileName);
char* copy_file_to_path_with_timestamp(const char* sourceFileName, const char* targetPath);

void ensure_trailing_separator(char* path, size_t size);
char* extract_basename(const char* path);
const char* imprort_mp3_generate_lrc(const char* mp3_path, const char* lrc_path);

int is_valid_utf8(const unsigned char* data, size_t len);
EncodingType detect_file_encoding_advanced(const char* filename);
char* read_file_with_auto_encoding(const char* filename, EncodingType* detected_encoding);
char* convert_encoding(const char* src, EncodingType src_encoding, EncodingType dst_encoding);
const char* skip_lrc_header(const char* content);
char* read_lrc1_until_first_lyric(const char* lrc_path1);
int merge_lrc_files_improved(const char* lrc_path1, const char* lrc_path2);

#endif // MP3_IMPORT_H_INCLUDED
